import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSAppView } from '../../app/view/ipsapp-view';
import { IPSControlXDataContainer } from '../ipscontrol-xdata-container';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { PSControlItemImpl } from '../pscontrol-item-impl';
import { IPSDEContextMenu } from '../toolbar/ipsdecontext-menu';
import { IPSDETreeNode } from './ipsdetree-node';
import { IPSDETreeNodeDataItem } from './ipsdetree-node-data-item';
import { IPSDETreeNodeRV } from './ipsdetree-node-rv';
import { IPSDERBase } from '../../dataentity/der/ipsderbase';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';

export class PSDETreeNodeImplBase extends PSControlItemImpl implements IPSDETreeNode, IPSControlXDataContainer {
  get counterId(): string {
    return this.M.counterId;
  }

  get counterMode(): 0 | 1 {
    return this.M.counterMode;
  }

  get modelObj(): string {
    return this.M.modelObj;
  }

  protected namepslanguageres: IPSLanguageRes | null = null;

  getNamePSLanguageRes(): IPSLanguageRes | null {
    if (this.namepslanguageres != null) return this.namepslanguageres;
    const value = this.M.getNamePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.namepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getNamePSLanguageRes') as IPSLanguageRes;
    return this.namepslanguageres;
  }

  get namePSLanguageRes(): IPSLanguageRes | null {
    return this.getNamePSLanguageRes();
  }

  getNamePSLanguageResMust(): IPSLanguageRes {
    const value = this.getNamePSLanguageRes();
    if (value == null) {
      throw new Error('未指定名称语言资源');
    }
    return value;
  }

  get navFilter(): string {
    return this.M.navFilter;
  }

  protected navpsappview: IPSAppView | null = null;

  getNavPSAppView(): IPSAppView | null {
    if (this.navpsappview != null) return this.navpsappview;
    const value = this.M.getNavPSAppView;
    if (value == null) {
      return null;
    }
    this.navpsappview = this.getPSModel4('app.view.IPSAppView', value, 'getNavPSAppView') as IPSAppView;
    return this.navpsappview;
  }

  get navPSAppView(): IPSAppView | null {
    return this.getNavPSAppView();
  }

  getNavPSAppViewMust(): IPSAppView {
    const value = this.getNavPSAppView();
    if (value == null) {
      throw new Error('未指定导航视图对象');
    }
    return value;
  }

  protected navpsder: IPSDERBase | null = null;

  getNavPSDER(): IPSDERBase | null {
    if (this.navpsder != null) return this.navpsder;
    const value = this.M.getNavPSDER;
    if (value == null) {
      return null;
    }
    this.navpsder = this.getPSModel4('dataentity.der.IPSDERBase', value, 'getNavPSDER') as IPSDERBase;
    return this.navpsder;
  }

  get navPSDER(): IPSDERBase | null {
    return this.getNavPSDER();
  }

  getNavPSDERMust(): IPSDERBase {
    const value = this.getNavPSDER();
    if (value == null) {
      throw new Error('未指定导航关系');
    }
    return value;
  }

  get navViewParamJO(): IModel {
    return this.M.navViewParamJO;
  }

  get nodeType(): string {
    return this.M.nodeType;
  }

  protected psappdataentity: IPSAppDataEntity | null = null;

  getPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.psappdataentity != null) return this.psappdataentity;
    const value = this.M.getPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.psappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getPSAppDataEntity') as IPSAppDataEntity;
    return this.psappdataentity;
  }

  get psAppDataEntity(): IPSAppDataEntity | null {
    return this.getPSAppDataEntity();
  }

  getPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定应用实体对象');
    }
    return value;
  }

  protected psdecontextmenu: IPSDEContextMenu | null = null;

  getPSDEContextMenu(): IPSDEContextMenu | null {
    if (this.psdecontextmenu != null) return this.psdecontextmenu;
    const value = this.M.getPSDEContextMenu;
    if (value == null) {
      return null;
    }
    this.psdecontextmenu = this.getPSModel4('control.toolbar.IPSDEContextMenu', value, 'getPSDEContextMenu') as IPSDEContextMenu;
    return this.psdecontextmenu;
  }

  get psDEContextMenu(): IPSDEContextMenu | null {
    return this.getPSDEContextMenu();
  }

  getPSDEContextMenuMust(): IPSDEContextMenu {
    const value = this.getPSDEContextMenu();
    if (value == null) {
      throw new Error('未指定上下文菜单对象');
    }
    return value;
  }

  protected psdetreenodedataitems: IPSDETreeNodeDataItem[] | null = null;

  getPSDETreeNodeDataItems(): IPSDETreeNodeDataItem[] | null {
    if (this.psdetreenodedataitems == null) {
      this.psdetreenodedataitems = this.fillChildListModel(this.M.getPSDETreeNodeDataItems, 'control.tree.IPSDETreeNodeDataItem') as IPSDETreeNodeDataItem[];
    }
    return this.psdetreenodedataitems;
  }

  get psDETreeNodeDataItems(): IPSDETreeNodeDataItem[] | null {
    return this.getPSDETreeNodeDataItems();
  }

  findPSDETreeNodeDataItem(objKey: any): IPSDETreeNodeDataItem | null {
    return this.getPSModel5('control.tree.IPSDETreeNodeDataItem', this.getPSDETreeNodeDataItems(), objKey) as IPSDETreeNodeDataItem;
  }

  protected psdetreenodervs: IPSDETreeNodeRV[] | null = null;

  getPSDETreeNodeRVs(): IPSDETreeNodeRV[] | null {
    if (this.psdetreenodervs == null) {
      this.psdetreenodervs = this.fillChildListModel(this.M.getPSDETreeNodeRVs, 'control.tree.IPSDETreeNodeRV') as IPSDETreeNodeRV[];
    }
    return this.psdetreenodervs;
  }

  get psDETreeNodeRVs(): IPSDETreeNodeRV[] | null {
    return this.getPSDETreeNodeRVs();
  }

  findPSDETreeNodeRV(objKey: any): IPSDETreeNodeRV | null {
    return this.getPSModel5('control.tree.IPSDETreeNodeRV', this.getPSDETreeNodeRVs(), objKey) as IPSDETreeNodeRV;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定节点界面样式表');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定节点图标对象');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端绘制插件');
    }
    return value;
  }

  get treeNodeType(): 'STATIC' | 'DE' | 'CODELIST' {
    return this.M.treeNodeType;
  }

  get hasPSDETreeNodeRSs(): boolean {
    return this.M.hasPSDETreeNodeRSs;
  }

  getHasPSDETreeNodeRSs(): boolean {
    return this.M.hasPSDETreeNodeRSs;
  }

  get allowDrag(): boolean {
    return this.M.allowDrag != null ? this.M.allowDrag : false;
  }

  get allowDrop(): boolean {
    return this.M.allowDrop != null ? this.M.allowDrop : false;
  }

  get allowEditText(): boolean {
    return this.M.allowEditText != null ? this.M.allowEditText : false;
  }

  get allowOrder(): boolean {
    return this.M.allowOrder != null ? this.M.allowOrder : false;
  }

  get appendPNodeId(): boolean {
    return this.M.appendPNodeId;
  }

  get disableSelect(): boolean {
    return this.M.disableSelect;
  }

  get enableCheck(): boolean {
    return this.M.enableCheck;
  }

  get enableEditData(): boolean {
    return this.M.enableEditData;
  }

  get enableExport(): boolean {
    return this.M.enableExport != null ? this.M.enableExport : false;
  }

  get enableFilter(): boolean {
    return this.M.enableFilter;
  }

  get enableImport(): boolean {
    return this.M.enableImport != null ? this.M.enableImport : false;
  }

  get enableNewData(): boolean {
    return this.M.enableNewData;
  }

  get enableQuickCreate(): boolean {
    return this.M.enableQuickCreate;
  }

  get enableQuickSearch(): boolean {
    return this.M.enableQuickSearch;
  }

  get enableRemoveData(): boolean {
    return this.M.enableRemoveData;
  }

  get enableSearch(): boolean {
    return this.M.enableSearch != null ? this.M.enableSearch : false;
  }

  get enableViewData(): boolean {
    return this.M.enableViewData;
  }

  get expandFirstOnly(): boolean {
    return this.M.expandFirstOnly;
  }

  get expanded(): boolean {
    return this.M.expanded;
  }

  get loadDefault(): boolean {
    return this.M.loadDefault != null ? this.M.loadDefault : true;
  }

  get pickupMode(): boolean {
    return this.M.pickupMode != null ? this.M.pickupMode : false;
  }

  get readOnly(): boolean {
    return this.M.readOnly != null ? this.M.readOnly : false;
  }

  get rootNode(): boolean {
    return this.M.rootNode;
  }

  get selectFirstOnly(): boolean {
    return this.M.selectFirstOnly;
  }

  get selected(): boolean {
    return this.M.selected;
  }

  get cls(): string {
    return 'PSDETreeNodeImplBase';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelObject' ||
      cls == 'IPSObject' ||
      cls == 'control.IPSControlMDataContainer' ||
      cls == 'control.IPSControlObjectNavigatable' ||
      cls == 'control.IPSControlXDataContainer' ||
      cls == 'control.IPSNavigatable' ||
      cls == 'control.IPSNavigateParamContainer' ||
      cls == 'control.tree.IPSDETreeNode'
    )
      return true;
    return super.instanceof(cls);
  }
}
